interface Person {
  name: string
  age?: number
  sayHi: () => void
}

let person1: Person = {
  name: 'zhangsan',
  age: 30,
  sayHi () {}
}
console.log('---person1---', person1)

interface Point2D {
  x: number
  y: number
}

// 接口相对于对象来说，它支持继承
interface Point3D extends Point2D {
  z: number
}

let point: Point3D = {
  x: 100,
  y: 100,
  z: 100
}
console.log('---point---', point)

type Object2D = {
  x: number
  y: number
}

// 如果想要实现接口中类似于继承的功能，在类型别名中可以使用交叉类型 &
// 类型别名不光可以用来定义对象，还可以用来定义其它类型，但是接口只能用来定义对象类型
type Object3D = Object2D & {
  z: number
}

let objectPoint: Object3D = {
  x: 200,
  y: 200,
  z: 200
}

console.log('---objectPoint---', objectPoint)

export {}
